package net.ddns.xcyyds.kungfu.procedures;

import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.Entity;
import net.minecraft.network.chat.TextComponent;

import net.ddns.xcyyds.kungfu.network.KungFuModVariables;

public class ShuLianDuAddNeiLiProcedure {
	public static void execute(Entity entity) {
		if (entity == null)
			return;
		{
			double _setval = (entity.getCapability(KungFuModVariables.PLAYER_VARIABLES_CAPABILITY, null)
					.orElse(new KungFuModVariables.PlayerVariables())).shuLianDuLevel + 1;
			entity.getCapability(KungFuModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
				capability.shuLianDuLevel = _setval;
				capability.syncPlayerVariables(entity);
			});
		}
		{
			double _setval = (entity.getCapability(KungFuModVariables.PLAYER_VARIABLES_CAPABILITY, null)
					.orElse(new KungFuModVariables.PlayerVariables())).neiLiMax
					+ Math.pow((entity.getCapability(KungFuModVariables.PLAYER_VARIABLES_CAPABILITY, null)
							.orElse(new KungFuModVariables.PlayerVariables())).shuLianDuLevel * 6, 0.5);
			entity.getCapability(KungFuModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
				capability.neiLiMax = _setval;
				capability.syncPlayerVariables(entity);
			});
		}
		{
			double _setval = (entity.getCapability(KungFuModVariables.PLAYER_VARIABLES_CAPABILITY, null)
					.orElse(new KungFuModVariables.PlayerVariables())).neiLiMax * 0.005;
			entity.getCapability(KungFuModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
				capability.neiLiAdd = _setval;
				capability.syncPlayerVariables(entity);
			});
		}
		if (entity instanceof Player _player && !_player.level.isClientSide())
			_player.displayClientMessage(new TextComponent("\u4F60\u7684\u5185\u529B\u503C\u4E0A\u9650\u4E0A\u5347\u4E86\uFF01"), (false));
	}
}
